package com.tiny.work.community.dubbo;

import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/config/spring/local/appcontext-*.xml"})

public class AbstractTestClass {



    static Session session = null;

    protected static void sshConnect() {
        try {
            JSch jsch = new JSch();
            session = jsch.getSession("xfsh", "10.50.110.11", 20777);
            session.setPassword("2c8b78a6943ad98abebe930704c827b7");
            session.setConfig("StrictHostKeyChecking", "no");
            session.connect();
//            session.setPortForwardingL(60001, "10.50.20.212", 60014);
            session.setPortForwardingL(60001, "10.50.20.211", 60025);
//            session.setPortForwardingL(60001, "10.50.20.152", 60014);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    protected void sshDisconnect() {
        if (null != session) {
            session.disconnect();
        }
    }
}
